StupidBeauty
Read times:840Posted at:Sat Dec 28 21:12:10 2013
- no title specified

Ext JS 4.2.0文档翻译: Ext.form.field.Checkbox

单个的复选框字段。可用来直接替换掉传统的复选框字段。同时也是单选按钮的亲代类。

文字标签

除了标准的字段文字标签属性之外,还可以给复选框设置一个可选的boxLabel,它会显示在复选框的后面。另外,参考Ext.form.CheckboxGroup以了解一种方便地将相关复选框分为一组的方法。

复选框的主要值是一个逻辑值,表示着该复选框是否处于选中状态。以下这些值会使复选框处于选中状态:

  • •. true

  • •. 'true'

  • •. '1'

  • •. 'on'

任何的其它值都会使得复选框处于未选中状态。

除了主要的逻辑值之外,妳还可以指定一个单独的输入值。当表单被提交时,这个额外的值会被作为参数值提交。如果妳有多个具有相同名字的复选框,那么妳就需要设置这个值了。如果没有指定的话,则会使用on 这个值。

使用示例

Ext.create (' Ext.form.Panel ', {

bodyPadding: 10,

width: 300,

title: 'Pizza Order',

items: [

{

xtype: 'fieldcontainer',

fieldLabel: 'Toppings',

defaultType: 'checkboxfield',

items: [

{

boxLabel : 'Anchovies',

name : 'topping',

inputValue: '1',

id : 'checkbox1'

}, {

boxLabel : 'Artichoke Hearts',

name : 'topping',

inputValue: '2',

checked : true,

id : 'checkbox2'

}, {

boxLabel : 'Bacon',

name : 'topping',

inputValue: '3',

id : 'checkbox3'

}

]

}

],

bbar: [

{

text: 'Select Bacon',

handler: function() {

Ext.getCmp ('checkbox3').setValue(true);

}

},

'-',

{

text: 'Select All',

handler: function() {

Ext.getCmp ('checkbox1').setValue(true);

Ext.getCmp ('checkbox2').setValue(true);

Ext.getCmp ('checkbox3').setValue(true);

}

},

{

text: 'Deselect All',

handler: function() {

Ext.getCmp ('checkbox1').setValue(false);

Ext.getCmp ('checkbox2').setValue(false);

Ext.getCmp ('checkbox3').setValue(false);

}

}

],

renderTo: Ext.getBody ()

});

配置选项

Ext.form.field.Checkbox

boxLabel : String

一个可选的文字标签,会出现在复选框旁边。至于它是出现在复选框之前还是复选框之后,这一点是由boxLabelAlign这个配置选项决定的。

Ext.form.field.Checkbox

boxLabelAlign : String

boxLabel应当相对于复选框出现的位置。可用的值是'before'和'after'。

默认值:'after'

Ext.form.field.Checkbox

checked : Boolean

如果为真,则表示这个复选框一开始就应当处于选中状态。

默认值:false

Ext.form.field.Checkbox

inputValue : String

在提交表单时,应当作为对应生成的输入元素的值属性并且用作参数值的值。

默认值:'on'

Ext.AbstractComponent

renderTo : String/HTMLElement/Ext.Element

指定要将此组件渲染到其中的:那个元素的id、那个DOM元素、或那个已有的元素(Element)。

注意:

如果此组件(Component)是某个容器中的一个子代条目,则不要使用这个选项。在那种情况下,是由该容器布局管理器负责来渲染及管理它的子代条目的。

如果妳使用了这个选项,则不需要调用render()

参考:render

2.3.0版本之后可用

Ext.form.field.Field

value : Object

一个用来初始化这个字段的值。

方法

实例方法

Ext.form.field.Checkbox

getValue( ) : Boolean

返回这个复选框的选中状态。

返回

  • •. Boolean

    如果被选中则返回真(True),否则返回假(false)

覆盖:Ext.form.field.Base.getValue

Ext.form.field.Checkbox

setValue( checked ) : Ext.form.field.Checkbox chainable

设置此复选框的选中状态,并且触发变更检测。

参数

  • •.checked : Boolean/String

    以下值会使得该复选框被选中:true、'true'、'1'、或'on'。另外,一个与inputValue相等的字符串(String)也会使得该复选框被选中。任何其它值会使得该复选框不被选中。

返回

覆盖:Ext.form.field.Base.setValue

事件

Ext.form.field.Field

change( this, newValue, oldValue, eOpts )

当某个字段的值被通过setValue方法改变时,会触发这个事件。

参数

未知美人

Your opinions
Your name:Email:Website url:Opinion content:
- no title specified

HxLauncher: Launch Android applications by voice commands